class sqstack:
    def __init__(self):
        self.data=[]
    def push(self,e):
        self.data.append(e)
    def pop(self):
        assert not self.empty()
        return self.data.pop()
    def empty(self):
        if len(self.data)==0:
            return True
        return False
    def gettop(self):
        assert not self.empty()
        return  self.data[-1]
def ispalindrome(str):
        st=sqstack()
        n=len(str)
        i=0
        while i<n//2:
            st.push(str[i])
            i+=1
        if n%2==1:
            i+=1
        while i<n:
            if st.pop()!=str[i]:
                return False
            i+=1
        return True
print("测试1")
str='abcba'
if ispalindrome(str):
    print(str+"是回文")
else:
    print(str+"不是回文")
print("测试2")
str='1221'
if ispalindrome(str):
    print(str + "是回文")
else:
    print(str + "不是回文")
